package simulateOS.entity;

public class Disk {
    private int diskNum;/*磁盘号*/
    private int index;/*磁盘参数，0为空闲磁盘,或者存储下一磁盘盘块号，若为-1则为结束盘块*/
    private boolean begin;/*是否为某文件的起始磁盘*/
    private String type;
    private Object object;

    public Disk(int diskNum, int index, String type, Object object) {
        this.diskNum = diskNum;
        this.index = index;
        this.type = type;
        this.object = object;
        this.begin = false;
    }

    public int getDiskNum() {
        return diskNum;
    }

    public void setDiskNum(int diskNum) {
        this.diskNum = diskNum;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public boolean isBegin() {
        return begin;
    }

    public void setBegin(boolean begin) {
        this.begin = begin;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    public void allocBlock(int index, String type, Object object, boolean begin) {
        this.setIndex(index);
        this.setType(type);
        this.setObject(object);
        this.setBegin(begin);
    }

    public void clearBlock() {
        this.setIndex(0);
        this.setType("空");
        this.setObject((Object)null);
        this.setBegin(false);
    }

    public boolean isFreeBlock() {
        return this.index == 0;
    }
}
